using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Globalization;
using System.Resources;
using Net.SamuelChen.Libs.DataAccess;
using Net.SamuelChen.Libs.WinForm.Calendar;

namespace Net.SamuelChen.Production.SmartAssistant.Calendar
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class fmCalendar : System.Windows.Forms.Form
	{
		private System.Windows.Forms.NotifyIcon NotifyIcon;
		private System.Windows.Forms.ContextMenu MainMenu;
		private System.Windows.Forms.TabControl tabMain;
		private System.Windows.Forms.TabPage tabPage1;
		private System.Windows.Forms.TabPage tabPage2;
		private System.Windows.Forms.TabPage tabPage3;
		private System.Windows.Forms.GroupBox gboxTime;
		private System.Windows.Forms.GroupBox gboxDate;
		private System.Windows.Forms.ComboBox cmbMonth;
		private System.Windows.Forms.NumericUpDown numYear;
		private Net.SamuelChen.Libs.WinForm.Calendar.MonthView monthView;
		private System.ComponentModel.IContainer components;
        private Net.SamuelChen.Libs.WinForm.Tricks.TraditinalClock traditinalClock1;
		private System.Windows.Forms.ColumnHeader colDesc;
		private System.Windows.Forms.ColumnHeader colBegin;
		private System.Windows.Forms.ColumnHeader colEnd;
		private System.Windows.Forms.ColumnHeader colID;

		private DateTime activeDate = DateTime.Today;
        private Net.SamuelChen.Libs.WinForm.Calendar.DayListView dayListView;
		private System.Windows.Forms.DateTimePicker dtTime;
		private System.Windows.Forms.Label lblInfo;

		public fmCalendar()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			monthView.ActiveDate = DateTime.Today;

			Initialize();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(fmCalendar));
			this.NotifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
			this.MainMenu = new System.Windows.Forms.ContextMenu();
			this.tabMain = new System.Windows.Forms.TabControl();
			this.tabPage1 = new System.Windows.Forms.TabPage();
			this.lblInfo = new System.Windows.Forms.Label();
			this.gboxTime = new System.Windows.Forms.GroupBox();
			this.dtTime = new System.Windows.Forms.DateTimePicker();
            this.traditinalClock1 = new Net.SamuelChen.Libs.WinForm.Tricks.TraditinalClock();
			this.gboxDate = new System.Windows.Forms.GroupBox();
            this.monthView = new Net.SamuelChen.Libs.WinForm.Calendar.MonthView();
			this.numYear = new System.Windows.Forms.NumericUpDown();
			this.cmbMonth = new System.Windows.Forms.ComboBox();
			this.tabPage2 = new System.Windows.Forms.TabPage();
			this.tabPage3 = new System.Windows.Forms.TabPage();
            this.dayListView = new Net.SamuelChen.Libs.WinForm.Calendar.DayListView();
			this.colDesc = new System.Windows.Forms.ColumnHeader();
			this.colBegin = new System.Windows.Forms.ColumnHeader();
			this.colEnd = new System.Windows.Forms.ColumnHeader();
			this.colID = new System.Windows.Forms.ColumnHeader();
			this.tabMain.SuspendLayout();
			this.tabPage1.SuspendLayout();
			this.gboxTime.SuspendLayout();
			this.gboxDate.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.numYear)).BeginInit();
			this.SuspendLayout();
			// 
			// NotifyIcon
			// 
			this.NotifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIcon.Icon")));
			this.NotifyIcon.Text = resources.GetString("NotifyIcon.Text");
			this.NotifyIcon.Visible = ((bool)(resources.GetObject("NotifyIcon.Visible")));
			// 
			// MainMenu
			// 
			this.MainMenu.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("MainMenu.RightToLeft")));
			// 
			// tabMain
			// 
			this.tabMain.AccessibleDescription = resources.GetString("tabMain.AccessibleDescription");
			this.tabMain.AccessibleName = resources.GetString("tabMain.AccessibleName");
			this.tabMain.Alignment = ((System.Windows.Forms.TabAlignment)(resources.GetObject("tabMain.Alignment")));
			this.tabMain.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("tabMain.Anchor")));
			this.tabMain.Appearance = ((System.Windows.Forms.TabAppearance)(resources.GetObject("tabMain.Appearance")));
			this.tabMain.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("tabMain.BackgroundImage")));
			this.tabMain.Controls.Add(this.tabPage1);
			this.tabMain.Controls.Add(this.tabPage2);
			this.tabMain.Controls.Add(this.tabPage3);
			this.tabMain.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("tabMain.Dock")));
			this.tabMain.Enabled = ((bool)(resources.GetObject("tabMain.Enabled")));
			this.tabMain.Font = ((System.Drawing.Font)(resources.GetObject("tabMain.Font")));
			this.tabMain.HotTrack = true;
			this.tabMain.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("tabMain.ImeMode")));
			this.tabMain.ItemSize = ((System.Drawing.Size)(resources.GetObject("tabMain.ItemSize")));
			this.tabMain.Location = ((System.Drawing.Point)(resources.GetObject("tabMain.Location")));
			this.tabMain.Name = "tabMain";
			this.tabMain.Padding = ((System.Drawing.Point)(resources.GetObject("tabMain.Padding")));
			this.tabMain.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("tabMain.RightToLeft")));
			this.tabMain.SelectedIndex = 0;
			this.tabMain.ShowToolTips = ((bool)(resources.GetObject("tabMain.ShowToolTips")));
			this.tabMain.Size = ((System.Drawing.Size)(resources.GetObject("tabMain.Size")));
			this.tabMain.TabIndex = ((int)(resources.GetObject("tabMain.TabIndex")));
			this.tabMain.Text = resources.GetString("tabMain.Text");
			this.tabMain.Visible = ((bool)(resources.GetObject("tabMain.Visible")));
			// 
			// tabPage1
			// 
			this.tabPage1.AccessibleDescription = resources.GetString("tabPage1.AccessibleDescription");
			this.tabPage1.AccessibleName = resources.GetString("tabPage1.AccessibleName");
			this.tabPage1.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("tabPage1.Anchor")));
			this.tabPage1.AutoScroll = ((bool)(resources.GetObject("tabPage1.AutoScroll")));
			this.tabPage1.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("tabPage1.AutoScrollMargin")));
			this.tabPage1.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("tabPage1.AutoScrollMinSize")));
			this.tabPage1.BackColor = System.Drawing.Color.GhostWhite;
			this.tabPage1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("tabPage1.BackgroundImage")));
			this.tabPage1.Controls.Add(this.lblInfo);
			this.tabPage1.Controls.Add(this.gboxTime);
			this.tabPage1.Controls.Add(this.gboxDate);
			this.tabPage1.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("tabPage1.Dock")));
			this.tabPage1.Enabled = ((bool)(resources.GetObject("tabPage1.Enabled")));
			this.tabPage1.Font = ((System.Drawing.Font)(resources.GetObject("tabPage1.Font")));
			this.tabPage1.ImageIndex = ((int)(resources.GetObject("tabPage1.ImageIndex")));
			this.tabPage1.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("tabPage1.ImeMode")));
			this.tabPage1.Location = ((System.Drawing.Point)(resources.GetObject("tabPage1.Location")));
			this.tabPage1.Name = "tabPage1";
			this.tabPage1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("tabPage1.RightToLeft")));
			this.tabPage1.Size = ((System.Drawing.Size)(resources.GetObject("tabPage1.Size")));
			this.tabPage1.TabIndex = ((int)(resources.GetObject("tabPage1.TabIndex")));
			this.tabPage1.Text = resources.GetString("tabPage1.Text");
			this.tabPage1.ToolTipText = resources.GetString("tabPage1.ToolTipText");
			this.tabPage1.Visible = ((bool)(resources.GetObject("tabPage1.Visible")));
			// 
			// lblInfo
			// 
			this.lblInfo.AccessibleDescription = resources.GetString("lblInfo.AccessibleDescription");
			this.lblInfo.AccessibleName = resources.GetString("lblInfo.AccessibleName");
			this.lblInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("lblInfo.Anchor")));
			this.lblInfo.AutoSize = ((bool)(resources.GetObject("lblInfo.AutoSize")));
			this.lblInfo.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("lblInfo.Dock")));
			this.lblInfo.Enabled = ((bool)(resources.GetObject("lblInfo.Enabled")));
			this.lblInfo.Font = ((System.Drawing.Font)(resources.GetObject("lblInfo.Font")));
			this.lblInfo.Image = ((System.Drawing.Image)(resources.GetObject("lblInfo.Image")));
			this.lblInfo.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblInfo.ImageAlign")));
			this.lblInfo.ImageIndex = ((int)(resources.GetObject("lblInfo.ImageIndex")));
			this.lblInfo.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("lblInfo.ImeMode")));
			this.lblInfo.Location = ((System.Drawing.Point)(resources.GetObject("lblInfo.Location")));
			this.lblInfo.Name = "lblInfo";
			this.lblInfo.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("lblInfo.RightToLeft")));
			this.lblInfo.Size = ((System.Drawing.Size)(resources.GetObject("lblInfo.Size")));
			this.lblInfo.TabIndex = ((int)(resources.GetObject("lblInfo.TabIndex")));
			this.lblInfo.Text = resources.GetString("lblInfo.Text");
			this.lblInfo.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("lblInfo.TextAlign")));
			this.lblInfo.Visible = ((bool)(resources.GetObject("lblInfo.Visible")));
			// 
			// gboxTime
			// 
			this.gboxTime.AccessibleDescription = resources.GetString("gboxTime.AccessibleDescription");
			this.gboxTime.AccessibleName = resources.GetString("gboxTime.AccessibleName");
			this.gboxTime.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("gboxTime.Anchor")));
			this.gboxTime.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("gboxTime.BackgroundImage")));
			this.gboxTime.Controls.Add(this.dtTime);
			this.gboxTime.Controls.Add(this.traditinalClock1);
			this.gboxTime.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("gboxTime.Dock")));
			this.gboxTime.Enabled = ((bool)(resources.GetObject("gboxTime.Enabled")));
			this.gboxTime.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.gboxTime.Font = ((System.Drawing.Font)(resources.GetObject("gboxTime.Font")));
			this.gboxTime.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("gboxTime.ImeMode")));
			this.gboxTime.Location = ((System.Drawing.Point)(resources.GetObject("gboxTime.Location")));
			this.gboxTime.Name = "gboxTime";
			this.gboxTime.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("gboxTime.RightToLeft")));
			this.gboxTime.Size = ((System.Drawing.Size)(resources.GetObject("gboxTime.Size")));
			this.gboxTime.TabIndex = ((int)(resources.GetObject("gboxTime.TabIndex")));
			this.gboxTime.TabStop = false;
			this.gboxTime.Text = resources.GetString("gboxTime.Text");
			this.gboxTime.Visible = ((bool)(resources.GetObject("gboxTime.Visible")));
			// 
			// dtTime
			// 
			this.dtTime.AccessibleDescription = resources.GetString("dtTime.AccessibleDescription");
			this.dtTime.AccessibleName = resources.GetString("dtTime.AccessibleName");
			this.dtTime.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("dtTime.Anchor")));
			this.dtTime.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("dtTime.BackgroundImage")));
			this.dtTime.CalendarFont = ((System.Drawing.Font)(resources.GetObject("dtTime.CalendarFont")));
			this.dtTime.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("dtTime.Dock")));
			this.dtTime.DropDownAlign = ((System.Windows.Forms.LeftRightAlignment)(resources.GetObject("dtTime.DropDownAlign")));
			this.dtTime.Enabled = ((bool)(resources.GetObject("dtTime.Enabled")));
			this.dtTime.Font = ((System.Drawing.Font)(resources.GetObject("dtTime.Font")));
			this.dtTime.Format = System.Windows.Forms.DateTimePickerFormat.Time;
			this.dtTime.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("dtTime.ImeMode")));
			this.dtTime.Location = ((System.Drawing.Point)(resources.GetObject("dtTime.Location")));
			this.dtTime.Name = "dtTime";
			this.dtTime.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("dtTime.RightToLeft")));
			this.dtTime.ShowUpDown = true;
			this.dtTime.Size = ((System.Drawing.Size)(resources.GetObject("dtTime.Size")));
			this.dtTime.TabIndex = ((int)(resources.GetObject("dtTime.TabIndex")));
			this.dtTime.Visible = ((bool)(resources.GetObject("dtTime.Visible")));
			// 
			// traditinalClock1
			// 
			this.traditinalClock1.AccessibleDescription = resources.GetString("traditinalClock1.AccessibleDescription");
			this.traditinalClock1.AccessibleName = resources.GetString("traditinalClock1.AccessibleName");
			this.traditinalClock1.ActiveTime = new System.DateTime(2006, 1, 5, 16, 49, 36, 704);
			this.traditinalClock1.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("traditinalClock1.Anchor")));
			this.traditinalClock1.AutoScroll = ((bool)(resources.GetObject("traditinalClock1.AutoScroll")));
			this.traditinalClock1.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("traditinalClock1.AutoScrollMargin")));
			this.traditinalClock1.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("traditinalClock1.AutoScrollMinSize")));
			this.traditinalClock1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("traditinalClock1.BackgroundImage")));
			this.traditinalClock1.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("traditinalClock1.Dock")));
			this.traditinalClock1.Enabled = ((bool)(resources.GetObject("traditinalClock1.Enabled")));
			this.traditinalClock1.Font = ((System.Drawing.Font)(resources.GetObject("traditinalClock1.Font")));
			this.traditinalClock1.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("traditinalClock1.ImeMode")));
			this.traditinalClock1.Location = ((System.Drawing.Point)(resources.GetObject("traditinalClock1.Location")));
			this.traditinalClock1.Name = "traditinalClock1";
			this.traditinalClock1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("traditinalClock1.RightToLeft")));
			this.traditinalClock1.Size = ((System.Drawing.Size)(resources.GetObject("traditinalClock1.Size")));
			this.traditinalClock1.TabIndex = ((int)(resources.GetObject("traditinalClock1.TabIndex")));
			this.traditinalClock1.Visible = ((bool)(resources.GetObject("traditinalClock1.Visible")));
			// 
			// gboxDate
			// 
			this.gboxDate.AccessibleDescription = resources.GetString("gboxDate.AccessibleDescription");
			this.gboxDate.AccessibleName = resources.GetString("gboxDate.AccessibleName");
			this.gboxDate.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("gboxDate.Anchor")));
			this.gboxDate.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("gboxDate.BackgroundImage")));
			this.gboxDate.Controls.Add(this.monthView);
			this.gboxDate.Controls.Add(this.numYear);
			this.gboxDate.Controls.Add(this.cmbMonth);
			this.gboxDate.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("gboxDate.Dock")));
			this.gboxDate.Enabled = ((bool)(resources.GetObject("gboxDate.Enabled")));
			this.gboxDate.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.gboxDate.Font = ((System.Drawing.Font)(resources.GetObject("gboxDate.Font")));
			this.gboxDate.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("gboxDate.ImeMode")));
			this.gboxDate.Location = ((System.Drawing.Point)(resources.GetObject("gboxDate.Location")));
			this.gboxDate.Name = "gboxDate";
			this.gboxDate.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("gboxDate.RightToLeft")));
			this.gboxDate.Size = ((System.Drawing.Size)(resources.GetObject("gboxDate.Size")));
			this.gboxDate.TabIndex = ((int)(resources.GetObject("gboxDate.TabIndex")));
			this.gboxDate.TabStop = false;
			this.gboxDate.Text = resources.GetString("gboxDate.Text");
			this.gboxDate.Visible = ((bool)(resources.GetObject("gboxDate.Visible")));
			// 
			// monthView
			// 
			this.monthView.AccessibleDescription = resources.GetString("monthView.AccessibleDescription");
			this.monthView.AccessibleName = resources.GetString("monthView.AccessibleName");
			this.monthView.ActiveDate = new System.DateTime(((long)(0)));
			this.monthView.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("monthView.Anchor")));
			this.monthView.AutoScroll = ((bool)(resources.GetObject("monthView.AutoScroll")));
			this.monthView.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("monthView.AutoScrollMargin")));
			this.monthView.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("monthView.AutoScrollMinSize")));
			this.monthView.BackColor = System.Drawing.SystemColors.ControlLightLight;
			this.monthView.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("monthView.BackgroundImage")));
			this.monthView.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.monthView.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("monthView.Dock")));
			this.monthView.Enabled = ((bool)(resources.GetObject("monthView.Enabled")));
			this.monthView.Font = ((System.Drawing.Font)(resources.GetObject("monthView.Font")));
			this.monthView.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("monthView.ImeMode")));
			this.monthView.Location = ((System.Drawing.Point)(resources.GetObject("monthView.Location")));
			this.monthView.Name = "monthView";
			this.monthView.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("monthView.RightToLeft")));
			this.monthView.Size = ((System.Drawing.Size)(resources.GetObject("monthView.Size")));
			this.monthView.TabIndex = ((int)(resources.GetObject("monthView.TabIndex")));
			this.monthView.Text = resources.GetString("monthView.Text");
			this.monthView.Visible = ((bool)(resources.GetObject("monthView.Visible")));
			this.monthView.CellClick += new Net.SamuelChen.Libs.WinForm.Calendar.CellClickHandler(this.monthView_CellClick);
            this.monthView.CellDoubleClick += new Net.SamuelChen.Libs.WinForm.Calendar.CellDoubleClickHandler(this.monthView_CellDoubleClick);
            this.monthView.MonthChanged += new Net.SamuelChen.Libs.WinForm.Calendar.MonthChangedHandler(this.monthView_MonthChanged);
			// 
			// numYear
			// 
			this.numYear.AccessibleDescription = resources.GetString("numYear.AccessibleDescription");
			this.numYear.AccessibleName = resources.GetString("numYear.AccessibleName");
			this.numYear.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("numYear.Anchor")));
			this.numYear.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("numYear.Dock")));
			this.numYear.Enabled = ((bool)(resources.GetObject("numYear.Enabled")));
			this.numYear.Font = ((System.Drawing.Font)(resources.GetObject("numYear.Font")));
			this.numYear.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("numYear.ImeMode")));
			this.numYear.Location = ((System.Drawing.Point)(resources.GetObject("numYear.Location")));
			this.numYear.Maximum = new System.Decimal(new int[] {
																	2099,
																	0,
																	0,
																	0});
			this.numYear.Minimum = new System.Decimal(new int[] {
																	1980,
																	0,
																	0,
																	0});
			this.numYear.Name = "numYear";
			this.numYear.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("numYear.RightToLeft")));
			this.numYear.Size = ((System.Drawing.Size)(resources.GetObject("numYear.Size")));
			this.numYear.TabIndex = ((int)(resources.GetObject("numYear.TabIndex")));
			this.numYear.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("numYear.TextAlign")));
			this.numYear.ThousandsSeparator = ((bool)(resources.GetObject("numYear.ThousandsSeparator")));
			this.numYear.UpDownAlign = ((System.Windows.Forms.LeftRightAlignment)(resources.GetObject("numYear.UpDownAlign")));
			this.numYear.Value = new System.Decimal(new int[] {
																  1982,
																  0,
																  0,
																  0});
			this.numYear.Visible = ((bool)(resources.GetObject("numYear.Visible")));
			this.numYear.ValueChanged += new System.EventHandler(this.numYear_ValueChanged);
			// 
			// cmbMonth
			// 
			this.cmbMonth.AccessibleDescription = resources.GetString("cmbMonth.AccessibleDescription");
			this.cmbMonth.AccessibleName = resources.GetString("cmbMonth.AccessibleName");
			this.cmbMonth.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("cmbMonth.Anchor")));
			this.cmbMonth.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("cmbMonth.BackgroundImage")));
			this.cmbMonth.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("cmbMonth.Dock")));
			this.cmbMonth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cmbMonth.Enabled = ((bool)(resources.GetObject("cmbMonth.Enabled")));
			this.cmbMonth.Font = ((System.Drawing.Font)(resources.GetObject("cmbMonth.Font")));
			this.cmbMonth.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("cmbMonth.ImeMode")));
			this.cmbMonth.IntegralHeight = ((bool)(resources.GetObject("cmbMonth.IntegralHeight")));
			this.cmbMonth.ItemHeight = ((int)(resources.GetObject("cmbMonth.ItemHeight")));
			this.cmbMonth.Location = ((System.Drawing.Point)(resources.GetObject("cmbMonth.Location")));
			this.cmbMonth.MaxDropDownItems = ((int)(resources.GetObject("cmbMonth.MaxDropDownItems")));
			this.cmbMonth.MaxLength = ((int)(resources.GetObject("cmbMonth.MaxLength")));
			this.cmbMonth.Name = "cmbMonth";
			this.cmbMonth.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("cmbMonth.RightToLeft")));
			this.cmbMonth.Size = ((System.Drawing.Size)(resources.GetObject("cmbMonth.Size")));
			this.cmbMonth.TabIndex = ((int)(resources.GetObject("cmbMonth.TabIndex")));
			this.cmbMonth.Text = resources.GetString("cmbMonth.Text");
			this.cmbMonth.Visible = ((bool)(resources.GetObject("cmbMonth.Visible")));
			this.cmbMonth.SelectedIndexChanged += new System.EventHandler(this.cmbMonth_SelectedIndexChanged);
			// 
			// tabPage2
			// 
			this.tabPage2.AccessibleDescription = resources.GetString("tabPage2.AccessibleDescription");
			this.tabPage2.AccessibleName = resources.GetString("tabPage2.AccessibleName");
			this.tabPage2.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("tabPage2.Anchor")));
			this.tabPage2.AutoScroll = ((bool)(resources.GetObject("tabPage2.AutoScroll")));
			this.tabPage2.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("tabPage2.AutoScrollMargin")));
			this.tabPage2.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("tabPage2.AutoScrollMinSize")));
			this.tabPage2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("tabPage2.BackgroundImage")));
			this.tabPage2.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("tabPage2.Dock")));
			this.tabPage2.Enabled = ((bool)(resources.GetObject("tabPage2.Enabled")));
			this.tabPage2.Font = ((System.Drawing.Font)(resources.GetObject("tabPage2.Font")));
			this.tabPage2.ImageIndex = ((int)(resources.GetObject("tabPage2.ImageIndex")));
			this.tabPage2.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("tabPage2.ImeMode")));
			this.tabPage2.Location = ((System.Drawing.Point)(resources.GetObject("tabPage2.Location")));
			this.tabPage2.Name = "tabPage2";
			this.tabPage2.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("tabPage2.RightToLeft")));
			this.tabPage2.Size = ((System.Drawing.Size)(resources.GetObject("tabPage2.Size")));
			this.tabPage2.TabIndex = ((int)(resources.GetObject("tabPage2.TabIndex")));
			this.tabPage2.Text = resources.GetString("tabPage2.Text");
			this.tabPage2.ToolTipText = resources.GetString("tabPage2.ToolTipText");
			this.tabPage2.Visible = ((bool)(resources.GetObject("tabPage2.Visible")));
			// 
			// tabPage3
			// 
			this.tabPage3.AccessibleDescription = resources.GetString("tabPage3.AccessibleDescription");
			this.tabPage3.AccessibleName = resources.GetString("tabPage3.AccessibleName");
			this.tabPage3.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("tabPage3.Anchor")));
			this.tabPage3.AutoScroll = ((bool)(resources.GetObject("tabPage3.AutoScroll")));
			this.tabPage3.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("tabPage3.AutoScrollMargin")));
			this.tabPage3.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("tabPage3.AutoScrollMinSize")));
			this.tabPage3.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("tabPage3.BackgroundImage")));
			this.tabPage3.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("tabPage3.Dock")));
			this.tabPage3.Enabled = ((bool)(resources.GetObject("tabPage3.Enabled")));
			this.tabPage3.Font = ((System.Drawing.Font)(resources.GetObject("tabPage3.Font")));
			this.tabPage3.ImageIndex = ((int)(resources.GetObject("tabPage3.ImageIndex")));
			this.tabPage3.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("tabPage3.ImeMode")));
			this.tabPage3.Location = ((System.Drawing.Point)(resources.GetObject("tabPage3.Location")));
			this.tabPage3.Name = "tabPage3";
			this.tabPage3.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("tabPage3.RightToLeft")));
			this.tabPage3.Size = ((System.Drawing.Size)(resources.GetObject("tabPage3.Size")));
			this.tabPage3.TabIndex = ((int)(resources.GetObject("tabPage3.TabIndex")));
			this.tabPage3.Text = resources.GetString("tabPage3.Text");
			this.tabPage3.ToolTipText = resources.GetString("tabPage3.ToolTipText");
			this.tabPage3.Visible = ((bool)(resources.GetObject("tabPage3.Visible")));
			// 
			// dayListView
			// 
			this.dayListView.AccessibleDescription = resources.GetString("dayListView.AccessibleDescription");
			this.dayListView.AccessibleName = resources.GetString("dayListView.AccessibleName");
			this.dayListView.Alignment = ((System.Windows.Forms.ListViewAlignment)(resources.GetObject("dayListView.Alignment")));
			this.dayListView.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("dayListView.Anchor")));
			this.dayListView.BackColor = System.Drawing.SystemColors.Info;
			this.dayListView.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("dayListView.BackgroundImage")));
			this.dayListView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.dayListView.CheckBoxes = true;
			this.dayListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																						  this.colDesc,
																						  this.colBegin,
																						  this.colEnd,
																						  this.colID});
			this.dayListView.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("dayListView.Dock")));
			this.dayListView.Enabled = ((bool)(resources.GetObject("dayListView.Enabled")));
			this.dayListView.Font = ((System.Drawing.Font)(resources.GetObject("dayListView.Font")));
			this.dayListView.FullRowSelect = true;
			this.dayListView.GridLines = true;
			this.dayListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
			this.dayListView.HoverSelection = true;
			this.dayListView.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("dayListView.ImeMode")));
			this.dayListView.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
																						((System.Windows.Forms.ListViewItem)(resources.GetObject("dayListView.Items")))});
			this.dayListView.LabelEdit = true;
			this.dayListView.LabelWrap = ((bool)(resources.GetObject("dayListView.LabelWrap")));
			this.dayListView.Location = ((System.Drawing.Point)(resources.GetObject("dayListView.Location")));
			this.dayListView.Name = "dayListView";
			this.dayListView.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("dayListView.RightToLeft")));
			this.dayListView.Size = ((System.Drawing.Size)(resources.GetObject("dayListView.Size")));
			this.dayListView.TabIndex = ((int)(resources.GetObject("dayListView.TabIndex")));
			this.dayListView.Text = resources.GetString("dayListView.Text");
			this.dayListView.View = System.Windows.Forms.View.Details;
			this.dayListView.Visible = ((bool)(resources.GetObject("dayListView.Visible")));
			this.dayListView.ItemActivate += new System.EventHandler(this.dayListView_ItemActivate);
			this.dayListView.Leave += new System.EventHandler(this.lstDate_Leave);
			this.dayListView.MouseLeave += new System.EventHandler(this.lstDate_Leave);
			// 
			// colDesc
			// 
			this.colDesc.Text = resources.GetString("colDesc.Text");
			this.colDesc.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("colDesc.TextAlign")));
			this.colDesc.Width = ((int)(resources.GetObject("colDesc.Width")));
			// 
			// colBegin
			// 
			this.colBegin.Text = resources.GetString("colBegin.Text");
			this.colBegin.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("colBegin.TextAlign")));
			this.colBegin.Width = ((int)(resources.GetObject("colBegin.Width")));
			// 
			// colEnd
			// 
			this.colEnd.Text = resources.GetString("colEnd.Text");
			this.colEnd.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("colEnd.TextAlign")));
			this.colEnd.Width = ((int)(resources.GetObject("colEnd.Width")));
			// 
			// colID
			// 
			this.colID.Text = resources.GetString("colID.Text");
			this.colID.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("colID.TextAlign")));
			this.colID.Width = ((int)(resources.GetObject("colID.Width")));
			// 
			// fmMain
			// 
			this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
			this.AccessibleName = resources.GetString("$this.AccessibleName");
			this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
			this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
			this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
			this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
			this.Controls.Add(this.dayListView);
			this.Controls.Add(this.tabMain);
			this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
			this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
			this.HelpButton = true;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
			this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
			this.MaximizeBox = false;
			this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
			this.MinimizeBox = false;
			this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
			this.Name = "fmMain";
			this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
			this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
			this.Text = resources.GetString("$this.Text");
			this.Closing += new System.ComponentModel.CancelEventHandler(this.fmMain_Closing);
			this.Load += new System.EventHandler(this.fmMain_Load);
			this.tabMain.ResumeLayout(false);
			this.tabPage1.ResumeLayout(false);
			this.gboxTime.ResumeLayout(false);
			this.gboxDate.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.numYear)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion


		/* ----------------------------
		 * ----- private methods ------
		 * ----------------------------
		 */

		private void Initialize(){
			string[] monthNames = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.MonthNames;
			for (int i=0; i<monthNames.Length-1; i++)
				cmbMonth.Items.Add(monthNames[i]);
			cmbMonth.SelectedIndex = activeDate.Month - 1;
			numYear.Value = activeDate.Year;
		}

		private void ShowScheduleOfDay(int x, int y, DateTime theDay) {
			dayListView.Top = y;
			dayListView.Left = x;
			dayListView.Width = 261;
			dayListView.Height = 150;
			dayListView.Columns[0].Text = theDay.ToString();
			dayListView.Items.Clear();

			DateTime begin = new DateTime(theDay.Year, theDay.Month, theDay.Day, 0, 0, 0);
			DateTime end = new DateTime(theDay.Year, theDay.Month, theDay.Day, 23, 59, 59);

			IList schedule = Database.GetScheduleListBetween(begin, end);

			ResourceManager resources = new ResourceManager(typeof(fmCalendar));
			dayListView.Items.AddRange(new ListViewItem[] {(
					(ListViewItem)(resources.GetObject("dayListView.Items")))});

			ScheduleItem item = null;
			for (int i=0; i<schedule.Count; i++) {
				item = (ScheduleItem)schedule[i];
				dayListView.Items.Add(new ListViewItem(
					new string[]{item.Description, item.DateStart.ToString(),
								item.DateStop.ToString(), item.ID.ToString()}));
			}

			dayListView.Show();
			dayListView.Focus();
		}

		/* ----------------------------
		 * ---------- events ----------
		 * ----------------------------
		 */

		private void fmMain_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			this.Hide();
			e.Cancel = true;
		}

		private void fmMain_Load(object sender, System.EventArgs e) {
			traditinalClock1.Start();
		}

		private void monthView_CellDoubleClick(CalendarMouseEventArgs e) {
			
		}

		private void monthView_CellClick(CalendarMouseEventArgs e) {
			
			activeDate = e.ActiveDate;
			cmbMonth.SelectedIndex = activeDate.Month - 1;
			numYear.Value = activeDate.Year;
			if (e.MouseEvent.Button == MouseButtons.Right) {
				ShowScheduleOfDay(e.MouseEvent.X, e.MouseEvent.Y, e.ActiveDate);
			}
		}

		private void lstDate_Leave(object sender, System.EventArgs e) {
			dayListView.Visible = false;
			dayListView.Refresh();
		}

		private void cmbMonth_SelectedIndexChanged(object sender, System.EventArgs e) {
			monthView.ActiveDate = new DateTime(monthView.ActiveDate.Year, 
				cmbMonth.SelectedIndex+1, monthView.ActiveDate.Day);
			monthView.Refresh();
		}

		private void numYear_ValueChanged(object sender, System.EventArgs e) {
			monthView.ActiveDate = new DateTime((int)numYear.Value, 
				monthView.ActiveDate.Month, monthView.ActiveDate.Day);
			monthView.Refresh();
		}

		private void dayListView_ItemActivate(object sender, System.EventArgs e) {
			DayListView lvDay = (DayListView)sender;
			ListViewItem lvItem = lvDay.SelectedItems[0];
			
			using (fmModifyScheduleItem fm = new fmModifyScheduleItem()) {
				if (lvItem.SubItems.Count == 4) {
					fm.ScheduleItem.ID = Convert.ToInt32(lvItem.SubItems[3].Text);
					fm.ScheduleItem.Description = lvItem.SubItems[0].Text;
					fm.ScheduleItem.DateStart = Convert.ToDateTime(lvItem.SubItems[1].Text);
					fm.ScheduleItem.DateStop = Convert.ToDateTime(lvItem.SubItems[2].Text);
					fm.ShowDialog(this);					
				} else {
					fm.ScheduleItem.DateStop = fm.ScheduleItem.DateStart = monthView.ActiveDate;
					fm.ShowDialog(this);
				}
				monthView_MonthChanged(null);
			}
		}

		private void monthView_MonthChanged(System.EventArgs e) {
			// mark month view
			bool[] scheduleDays = Database.GetScheduleDaysOfMonth(
				monthView.ActiveDate.Year, monthView.ActiveDate.Month);
			for (int i=1; i<scheduleDays.Length; i++) {
				if (scheduleDays[i])
					monthView.Mark(i);
			}		
		}

	}
}
